<extend name="./common" />
<block name='content'>
<div class="content-wrap"><!--内容-->
    <div class="content">
      <div class="content-block friendly-content row">
        <h2 class="title"><strong>本站友链</strong></h2>
        <foreach name='links' item='link'>
        <div class="col-md-4 col-xs-6"><span data-toggle="tooltip" data-placement="bottom" title="点击进入 {$link['name']} 站点"><a target="_blank" href="{$link['link']}">{$link['name']}</a></span>
          <p><strong>简介：</strong>{$link['describe']}</p>
        </div>
        </foreach>
      </div>
    <div class="content-block comment">
      <h2 class="title"><strong>提交友链</strong></h2>
      <form action="" method="post" class="form-inline" id="links-form">
        <div class="comment-title">
          <div class="form-group">
            <label for="name">网站名称：</label>
            <input type="text" name="name" class="form-control" id="blogname" placeholder="XX博客">
          </div>
          <div class="form-group">
            <label for="link">网站地址：</label>
            <input type="text" name="link" class="form-control" id="link" placeholder="http://baagee.vip" value="http://">
          </div>
        </div>
        <div class="comment-title">
            <div class="form-group">
              <label for="commentName">你的邮箱：</label>
              <input type="email" name="email" placeholder="便于收到通知" class="form-control" id="email">
            </div>
          </div>
        <div class="comment-title">
            <div class="form-group">
              <label for="commentName">验证码：</label>
              <input type="text" name="nickname" placeholder="验证码" maxlength="4" class="form-control" id="code">
            </div>
            <div class="form-group">
              <img style="display: block;border: 1px solid #ccc;" src="__CONTROLLER__/verify" class="comment-form-text"  onclick="this.src='__CONTROLLER__/verify/'+Math.random()" id="verifyImg">
              <span style="    line-height: 37px;    margin-left: 10px;">点击图片切换</span>
            </div>
          </div>
        <div class="comment-form">
          <textarea placeholder="请填写网站服务内容" name="describe" id="describe"></textarea>
          <div class="comment-form-footer">
            <!-- <div class="comment-form-text">请先 <a href="javascript:;">登录</a> 或 <a href="javascript:;">注册</a>，也可匿名提交友链 </div> -->
            <div class="comment-form-btn">
              <button type="submit" class="btn btn-default btn-comment">提交友链</button>
            </div>
          </div>
        </div>
      </form>
    </div>
  </div>
  </div>
</block>
<block name='js'>
	<script type="text/javascript">
		$("#links-form").submit(function(){
			var name=$.trim($("#blogname").val());
			var link=$("#link").val();
      var describe=$("#describe").val();
      var code=$("#code").val();
			var email=$("#email").val();
			if(name==''){
				layer.alert('名称不能为空');
				return false;
			}
      if(link=='' ){
        layer.alert('地址不能为空');
        return false;
      }
      if(email==''){
        layer.alert('邮箱不能为空');
        return false; 
      }
			$.post('{:U("index/links")}',{'name':name,'link':link,'describe':describe,'code':code,'email':email},function(res){
				if(res.status){
					layer.msg(res.msg);
				}else{
					layer.alert(res.msg);
				}
			});
			return false;
		})
	</script>
</block>